package com.se.hospitalmonitoring;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Set;

import com.se.hospitalmonitoring.VitalSign.VitalSignMeasurement;

public class PatientRecord {
	public long id = -1L;
	public String name = null;
	public int age = -1;
	public VitalSignHistory history = new VitalSignHistory();

	/**
	 * Constructor
	 * 
	 * @param id
	 *            The id of the patient
	 * @param name
	 *            The name of the patient
	 */
	public PatientRecord(long id, String name, int age) {
		this.id = id;
		this.name = name;
		this.age = age;
	}

	public static class VitalSignHistory {
		private final HashMap<VitalSign, ArrayList<VitalSignMeasurement>> history = new HashMap<VitalSign, ArrayList<VitalSignMeasurement>>();

		/**
		 * Constructor
		 */
		public VitalSignHistory() {

		}

		/**
		 * Adds a single vital sign measurement to the history
		 * 
		 * @param vsm
		 *            The vital sign measurement to add
		 */
		public void addVitalSignMeasurement(VitalSignMeasurement vsm) {
			if (!history.containsKey(vsm.vitalSign)) {
				history.put(vsm.vitalSign,
					new ArrayList<VitalSignMeasurement>());
			}
			history.get(vsm.vitalSign).add(vsm);
		}

		/**
		 * Gets the vital signs that have values in the history
		 * 
		 * @return The set of vital signs
		 */
		public Set<VitalSign> getVitalSigns() {
			return history.keySet();
		}

		/**
		 * Gets a list of history entries for the given vital sign
		 * 
		 * @param vitalSign
		 *            The vital sign to get history for
		 * @return A list of history entries
		 */
		public ArrayList<VitalSignMeasurement> getHistory(VitalSign vitalSign) {
			return history.get(vitalSign);
		}
	}
}
